package com.dropdb.demo.service.impl;


import com.dropdb.demo.mapper.SystemMapper;
import com.dropdb.demo.service.AdminConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dropdb.demo.bean.System;

import java.util.HashMap;
import java.util.Map;

/**
 * @author:cheyanjun
 * @date:2020/06/28 15:40
 */
@Service
public class AdminConfigServiceImpl implements AdminConfigService {

    @Autowired
    SystemMapper systemMapper;

    @Override
    public Map getMall() {
        HashMap malldata = new HashMap();
        String address = systemMapper.selectById(14);
        String name = systemMapper.selectById(6);
        String phone = systemMapper.selectById(12);
        String qq = systemMapper.selectById(8);
        malldata.put("cskaoyan_mall_mall_address", address);
        malldata.put("cskaoyan_mall_mall_name", name);
        malldata.put("cskaoyan_mall_mall_phone", phone);
        malldata.put("cskaoyan_mall_mall_qq", qq);
        return malldata;
    }

    @Override
    public void postMall(Map malldata) {
        System system1 = new System();
        system1.setId(14);
        system1.setKeyValue((String) malldata.get("cskaoyan_mall_mall_address"));
        systemMapper.updateByPrimaryKeySelective(system1);

        System system2 = new System();
        system2.setKeyValue((String) malldata.get("cskaoyan_mall_mall_name"));
        system2.setId(6);
        systemMapper.updateByPrimaryKeySelective(system2);


        System system3 = new System();
        system3.setKeyValue((String) malldata.get("cskaoyan_mall_mall_phone"));
        system3.setId(12);
        systemMapper.updateByPrimaryKeySelective(system3);

        System system4 = new System();
        system4.setKeyValue((String) malldata.get("cskaoyan_mall_mall_qq"));
        system4.setId(8);
        systemMapper.updateByPrimaryKeySelective(system4);
    }

    @Override
    public Map getExpress() {
        HashMap expressdata = new HashMap();
        String min = systemMapper.selectById(5);
        String value = systemMapper.selectById(7);
        expressdata.put("cskaoyan_mall_express_freight_min", min);
        expressdata.put("cskaoyan_mall_express_freight_value", value);
        return expressdata;
    }

    @Override
    public void postExpress(Map expressdata) {
        System system1 = new System();
        system1.setId(5);
        system1.setKeyValue((String) expressdata.get("cskaoyan_mall_express_freight_min"));
        systemMapper.updateByPrimaryKeySelective(system1);

        System system2 = new System();
        system2.setId(7);
        system2.setKeyValue((String) expressdata.get("cskaoyan_mall_express_freight_value"));
        systemMapper.updateByPrimaryKeySelective(system2);
    }

    @Override
    public Map getOrder() {
        HashMap orderdata = new HashMap();
        String comment = systemMapper.selectById(10);
        String unconfirm = systemMapper.selectById(3);
        String unpaid = systemMapper.selectById(1);
        orderdata.put("cskaoyan_mall_order_comment", comment);
        orderdata.put("cskaoyan_mall_order_unconfirm", unconfirm);
        orderdata.put("cskaoyan_mall_order_unpaid", unpaid);
        return orderdata;
    }

    @Override
    public void postOrder(Map orderdata) {
        System system1 = new System();
        system1.setId(10);
        system1.setKeyValue((String) orderdata.get("cskaoyan_mall_order_comment"));
        systemMapper.updateByPrimaryKeySelective(system1);

        System system2 = new System();
        system2.setId(3);
        system2.setKeyValue((String) orderdata.get("cskaoyan_mall_order_unconfirm"));
        systemMapper.updateByPrimaryKeySelective(system2);

        System system3 = new System();
        system3.setId(1);
        system3.setKeyValue((String) orderdata.get("cskaoyan_mall_order_unpaid"));
        systemMapper.updateByPrimaryKeySelective(system2);

    }

    @Override
    public Map getWx() {
        HashMap wxdata = new HashMap();
        String goods = systemMapper.selectById(11);
        String list = systemMapper.selectById(13);
        String brand = systemMapper.selectById(15);
        String indexhot = systemMapper.selectById(9);
        String indexnew = systemMapper.selectById(2);
        String topic = systemMapper.selectById(16);
        String share = systemMapper.selectById(4);
        wxdata.put("cskaoyan_mall_wx_catlog_goods", goods);
        wxdata.put("cskaoyan_mall_wx_catlog_list", list);
        wxdata.put("cskaoyan_mall_wx_index_brand", brand);
        wxdata.put("cskaoyan_mall_wx_index_hot", indexhot);
        wxdata.put("cskaoyan_mall_wx_index_new", indexnew);
        wxdata.put("cskaoyan_mall_wx_index_topic", topic);
        wxdata.put("cskaoyan_mall_wx_share", share);
        return wxdata;
    }

    @Override
    public void postWx(Map wxdata) {
        System system1 = new System();
        system1.setId(11);
        system1.setKeyValue((String) wxdata.get("cskaoyan_mall_wx_catlog_goods"));
        systemMapper.updateByPrimaryKeySelective(system1);

        System system2 = new System();
        system2.setId(13);
        system2.setKeyValue((String) wxdata.get("cskaoyan_mall_wx_catlog_list"));
        systemMapper.updateByPrimaryKeySelective(system2);

        System system3 = new System();
        system3.setId(15);
        system3.setKeyValue((String) wxdata.get("cskaoyan_mall_wx_index_brand"));
        systemMapper.updateByPrimaryKeySelective(system3);

        System system4 = new System();
        system4.setId(9);
        system4.setKeyValue((String) wxdata.get("cskaoyan_mall_wx_index_hot"));
        systemMapper.updateByPrimaryKeySelective(system4);

        System system5 = new System();
        system5.setId(2);
        system5.setKeyValue((String) wxdata.get("cskaoyan_mall_wx_index_new"));
        systemMapper.updateByPrimaryKeySelective(system5);


        System system6 = new System();
        system6.setId(16);
        system6.setKeyValue((String) wxdata.get("cskaoyan_mall_wx_index_topic"));
        systemMapper.updateByPrimaryKeySelective(system6);

        System system7 = new System();
        system7.setKeyValue(String.valueOf(wxdata.get("cskaoyan_mall_wx_share")) );
        system7.setId(4);
        systemMapper.updateByPrimaryKeySelective(system7);
    }


}
